<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="centre/manage/include :: header"></head>
<link rel="stylesheet" type="text/css" href="/css/plugins/layui/layui.css"/>
<link href="/css/jquery-select/jquery.searchableSelect.css" rel="stylesheet" type="text/css">
<body class="gray-bg">
	<div class="wrapper wrapper-content ">
		<div class="row">
			<div class="col-sm-12">
				<div class="ibox float-e-margins">
					<div class="ibox-content">
						<form class="form-horizontal m-t" id="editCommanderForm">
							<input type="hidden" th:value="${store.mid}" id="mid" name="mid">
							<input type="hidden" th:value="${store.id}" id="id" name="id">
							<input type="hidden" th:value="${store.businessTimeStr}" id="businessTimeStr" name="businessTimeStr">
							<table class="table table-bordered table-condensed">
								<tbody>
								<tr>
									<th class="required" style="text-align: right;">同步开关</th>
									<td>
										<label class="radio-inline"><input th:field="*{store.isSync}" type="radio" name="isSync" value="1"/>开启</label>
										<label class="radio-inline"><input th:field="*{store.isSync}" type="radio" name="isSync" value="0" />关闭</label>
									</td>
								</tr>
								<tr>
									<th class="required" style="text-align: right;">*门店名称</th>
									<td th:text="${store.storeName}"></td>
									<th class="required" style="text-align: right;">*门店联系电话</th>
									<td ><input id="phone" name="phone" class="form-control" type="text" th:value="${store.phone}"/></td>
								</tr>
								<tr>
									<th class="required" style="text-align: right;">门店编号:</th>
									<!--<td id="teamid" name="teamid" th:text="${store.teamid}"></td>-->
									<td><input id="teamid" name="teamid" class="form-control" type="text" th:value="${store.teamid}" readonly="readonly"/></td>

									<th class="required" style="text-align: right;">绑定餐道编号:</th>
									<td><input id="storeId" name="storeId" class="form-control" type="text" th:value="${store.storeId}"/></td>
								</tr>
								<!--<tr>-->
									<!--<th class="required" style="text-align: right;">*门店联系电话</th>-->
									<!--<td ><input id="phone" name="phone" class="form-control" type="text" th:value="${store.phone}"/></td>-->
								<!--</tr>-->
								<tr>
									<th class="required" style="text-align: right;">预计备餐时长</th>
									<td ><input id="avgProductTime" name="avgProductTime" class="form-control" type="text" th:value="${store.avgProductTime}"/></td>
									<th class="required" style="text-align: right;">预计配送时长</th>
									<td ><input id="waitTime" name="waitTime" class="form-control" type="text" th:value="${store.waitTime}"/></td>
								</tr>
								<!--<tr>-->
									<!--<th class="required" style="text-align: right;">*开始营业时间:</th>-->
									<!--<td><input id="businessBeginTime" name="businessBeginTime" class="form-control" type="text" th:value="${store.businessBeginTime}" placeholder="00:00:00"/></td>-->

									<!--<th class="required" style="text-align: right;">*结束营业时间:</th>-->
									<!--<td><input id="businessEndTime" name="businessEndTime" class="form-control" type="text" th:value="${store.businessEndTime}" placeholder="23:59:59"/></td>-->
								<!--</tr>-->
								<tr id="businessTime">
									<th class="required" style="text-align: right;">*营业时间:</th>
									<td>
										<a href="javascript:;" class='btn btn-primary' id='add-spec'
										   onclick="addSpec()" style="margin-top: 10px; margin-bottom: 10px;"
										   title="添加">
											<i class='fa fa-plus'></i> 添加
										</a>
									</td>
								</tr>
								<!--<tr>-->
									<!--<th class="required" style="text-align: right;">*最小预约时间(分):</th>-->
									<!--<td><input id="appointmentMin" name="appointmentMin" class="form-control" type="text" th:value="${store.appointmentMin}"/></td>-->

									<!--<th class="required" style="text-align: right;">*最大预约时间(分):</th>-->
									<!--<td><input id="appointmentMax" name="appointmentMax" class="form-control" type="text" th:value="${store.appointmentMax}"/></td>-->
								<!--</tr>-->
								<!--<tr>-->
									<!--<th class="required" style="text-align: right;">配送范围名称</th>-->
									<!--<td ><input id="rangeName" name="rangeName" class="form-control" type="text" th:value="${store.rangeName}"/></td>-->
								<!--</tr>-->
								<!--<tr>-->
									<!--<th class="required" style="text-align: right;">*范围类型</th>-->
									<!--<td>-->
										<!--<label class="radio-inline"><input th:field="*{store.rangeType}" type="radio" name="rangeType" value="2"/>圆半径</label>-->
										<!--<label class="radio-inline"><input th:field="*{store.rangeType}" type="radio" name="rangeType" value="3" />全城送</label>-->
									<!--</td>-->
									<!--<th class="required" style="text-align: right;">*半径（米）</th>-->
									<!--<td ><input id="radius" name="radius" class="form-control" type="text" th:value="${store.radius}"/></td>-->
								<!--</tr>-->
								<!--<tr>-->
									<!--<th class="required" style="text-align: right;">*开始配送时间:</th>-->
									<!--<td><input id="deliveryBeginTime" name="deliveryBeginTime" class="form-control" type="text" th:value="${store.deliveryBeginTime}" placeholder="00:00:00"/></td>-->

									<!--<th class="required" style="text-align: right;">*结束配送时间:</th>-->
									<!--<td><input id="deliveryEndTime" name="deliveryEndTime" class="form-control" type="text" th:value="${store.deliveryEndTime}" placeholder="23:59:59"/></td>-->
								<!--</tr>-->
								<!--<tr>-->
									<!--<th class="required" style="text-align: right;">*配送类型</th>-->
									<!--<td>-->
										<!--<label class="radio-inline"><input th:field="*{store.deliveryType}" type="radio" name="deliveryType" value="1"/>按份起送</label>-->
										<!--<label class="radio-inline"><input th:field="*{store.deliveryType}" type="radio" name="deliveryType" value="2" />按金额起送</label>-->
									<!--</td>-->
								<!--</tr>-->
								<!--<tr>-->
									<!--<th class="required" style="text-align: right;">*按份起送(份数):</th>-->
									<!--<td><input id="reachPart" name="reachPart" class="form-control" type="text" th:value="${store.reachPart}" /></td>-->

									<!--<th class="required" style="text-align: right;">*按金额起送(元):</th>-->
									<!--<td><input id="reachFee" name="reachFee" class="form-control" type="text" th:value="${store.reachFee}" /></td>-->
								<!--</tr>-->
								<!--<tr>-->
									<!--<th class="required" style="text-align: right;">*配送费</th>-->
									<!--<td ><input id="deliveryFee" name="deliveryFee" class="form-control" type="text" th:value="${store.deliveryFee}"/></td>-->
								<!--</tr>-->

								</tbody>
							</table>
							<div class="form-group text-center">
								<div class="col-sm-8 col-sm-offset-2">
									<button type="submit"  class="btn btn-primary"><i class="fa fa-check"></i>提交</button>
									<div class="btn btn-danger" onclick="closeDow()"><i class="fa fa-remove"></i> 关闭</div>
								</div>
							</div>
						</form>
					</div>
				</div>
			</div>
		</div>

	</div>
	<div th:include="centre/manage/include::footer"></div>
	<script type="text/javascript" src="/js/plugins/layui/layui.js"></script>
	<script type="text/javascript" src="/js/appjs/commander/manage/editStore.js"></script>
	  <script src="/js/jquery-select/jquery.searchableSelect.js"></script>
	
	<script type="text/javascript">
	$(function(){
		var flag =  $("#flag").val();
		if(flag==0){
			$('#centreId').searchableSelect();
		}
	});
		function closeDow() {
			var index = parent.layer.getFrameIndex(window.name); // 获取窗口索引
			parent.layer.close(index);
		}
		function getZuoBiao() {
			window.open("https://lbs.amap.com/console/show/picker");
		}

    var specCountNum = 1;

    function addSpec() {

        var html = '<tr class="business_item">'
         	+ '<th class="required" style="text-align: right;">营业时间:</th>'
        	+ '<td><input id="beginTime' + specCountNum + '" class="form-control begin_time" type="text" /></td>'
			+ '<th class="required" style="text-align: right;">-:</th>'
        	+ '<td><input id="endTime' + specCountNum + '"  class="form-control end_time" type="text" /></td>'
			+ '</tr>';

        $('#businessTime').append(html);

        specCountNum++;
    }

    $(function () {
        var id = $('#mid').val();
        $.ajax({
            url: '/commanderList/manage/storeDetail?id=' + id,
            contentType: "application/json",
            dataType: "json",
            type: 'GET',
            success: function (result) {
                if (result.businessTimeList != null && result.businessTimeList.length > 0) {
                    var html = '';
                    for (var i = 0; i < result.businessTimeList.length; i++) {
                        html += '<tr class="business_item">'
                            + '<th class="required" style="text-align: right;"></th>'
                            + '<td><input id="beginTime' + specCountNum + '" class="form-control begin_time" type="text" value="' + result.businessTimeList[i].beginTime + '" /></td>'
                            + '<th class="required" style="text-align: right;">-</th>'
                            + '<td><input id="endTime' + specCountNum + '"  class="form-control end_time" type="text" value="' + result.businessTimeList[i].endTime + '" /></td>'
                            + '</tr>';

                        specCountNum++;
                    }
                    $('#businessTime').append(html);
                }
            }
        })
    })
	</script>
</body>
</html>
